home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / baswiz19.zip / FDEMO.BAS < prev    next >
BASIC Source File  |  1993-01-29  |  3KB  |  69 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |         BASWIZ  Copyright (c) 1990-1993  Thomas G. Hanlin III        |
  4. '   |                                                                      |
  5. '   |                       The BASIC Wizard's Library                     |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8. '
  9. '  This demo provides a quick example for the BasWiz FAR STRING routines.
  10. '  It is for use with QuickBasic only-- PDS and VB/DOS have their own far
  11. '  string capabilities built into the language.
  12.  
  13.    DECLARE SUB FSDone ()
  14.    DECLARE FUNCTION FSGet$ (BYVAL Handle%)
  15.    DECLARE SUB FSInit (BYVAL UseEMS%)
  16.    DECLARE SUB FSSet (Handle%, St$)
  17.  
  18.    DEFINT A-Z
  19.    DIM HandleList(1 TO 100)
  20.  
  21.    UseEMS = (INSTR(COMMAND$, "/EMS") > 0)
  22.    UseMain = (INSTR(COMMAND$, "/MAIN") > 0)
  23.  
  24.    IF NOT (UseMain OR UseEMS) THEN
  25.       PRINT "FDEMO demonstrates the BasWiz far string handler by reading WDEMO.DAT into"
  26.       PRINT "memory and then displaying it.  You may specify far memory or EMS:"
  27.       PRINT "   FDEMO /MAIN      use main memory outside DGROUP"
  28.       PRINT "   FDEMO /EMS       use EMS memory (if available)"
  29.       END
  30.    END IF
  31.  
  32.    CLS
  33.    COLOR 0, 7
  34.    PRINT "FDEMO reads WDEMO.DAT into ";
  35.    IF UseEMS THEN PRINT "EMS"; ELSE PRINT "main";
  36.    PRINT " memory and then displays it, as a"
  37.    PRINT "demonstration of the BasWiz far string routines."
  38.    PRINT
  39.    COLOR 7, 0
  40.  
  41.    FSInit UseEMS                            ' initialize far string handler
  42.  
  43.    OPEN "WDEMO.DAT" FOR INPUT AS #1
  44.    DO UNTIL EOF(1) OR ErrCode
  45.       LINE INPUT#1, Text$
  46.       Handle = 0
  47.       FSSet Handle, Text$                   ' set far string
  48.       IF Handle = 0 THEN
  49.          ErrCode = -1                       ' set error code if out of memory
  50.       ELSE
  51.          MaxHandle = MaxHandle + 1          ' otherwise, save far str. handle
  52.          HandleList(MaxHandle) = Handle
  53.       END IF
  54.    LOOP
  55.    CLOSE
  56.  
  57.    IF ErrCode THEN
  58.       PRINT "Sorry, there wasn't enough memory available."
  59.       IF UseEMS THEN
  60.          PRINT "Try using main memory instead of EMS."
  61.       ELSE
  62.          PRINT "Try using EMS instead of main memory."
  63.       END IF
  64.    ELSE
  65.       FOR HandleNr = 1 TO MaxHandle
  66.          PRINT FSGet(HandleList(HandleNr))
  67.       NEXT
  68.    END IF
  69.